<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>编辑</title>
		<link rel="stylesheet" type="text/css" href="../../plugins/layui/css/layui.css" />
		<link href="../../kitAdmin/css/app.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" type="text/css" href="../../plugins/select2/dist/css/select2.min.css"/>
		<style type="text/css">
			.slcstyle{
				width: 190px !important;
				height: 38px !important;
			}
		</style>
	</head>

	<body>
		<div class='kit-table'>
			<div style='margin:10px'>
				
		<form class='layui-form' action='' lay-filter='form-edit'>
			<input type='hidden' name='id'  data-link='{:id}' />
			<div class='layui-form-item'>
				<div class='layui-inline'>
					<!--<input type="hidden" name="" />-->
					<label class='layui-form-label'>级别</label>
					<div class='layui-input-inline'>
						<select class="slcstyle" data-link='{:levelId}' placeholder='' id='_levelId' name='levelId'></select>
					</div>
				</div>
			</div>
			<div class='layui-form-item'>
				<div class='layui-inline'>
					<label class='layui-form-label'>年级/Group</label>
					<div class='layui-input-inline'>
						<input type='text' placeholder=''data-link='{:group_}' id='_group_' name='group_' class='layui-input'>
					</div>
				</div>
				
			</div>
			<div class='layui-form-item'>
				<div class='layui-inline'>
					<label class='layui-form-label'>备注</label>
					<div class='layui-input-inline'>
						<input type='text' placeholder=''data-link='{:remark}' id='_remark' name='remark' class='layui-input'>
					</div>
				</div>
			</div>
		</form>
			</div>
		</div>
		<script src="../../common/js/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../static/js/base.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../plugins/jsviews/jsviews.js" type="text/javascript"></script>
		<script src="../../plugins/select2/dist/js/select2.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var uid = getQueryVariable('id');
			var lessonId = getQueryVariable('lessonId');
			jQuery(document).ready(function() {
				bindFormData();
			});
			var callback_save=function(){
				var data=$('.layui-form').serialize();
				console.log(data);
				data+='&lessonId='+lessonId+'&levelName='+$('#_levelId').find('option:selected').text();
				return data;
			}
			function bindFormData(){

				if(uid){
					$.ajax({
						url:baseUrl+'/lessonLevels/'+uid,
						type:'get',
						success:function(data){
							var arr=[];
							$.ajax({
								url:baseUrl+'/levels',
								type:'get',
								async:false,
								success:function(levels){
									var dats=levels.rows;
									for(var j=0;j<dats.length;j++){
										var obj = {};
										obj.text = dats[j].name;
										obj.id = dats[j].id;
										if(dats[j].id==data.data.levelId){
											obj.selected=true;
										}
										arr.push(obj);
									}
								}
							});
							$('#_levelId').select2({
								data: arr
							});
							data.data.lessonId=lessonId;
							$.link(true, ".kit-table", data.data);
							$('select').select2().change();
						},
						error:function(){
							parent.layer.alert('系统或网络错误！');
						}
					});
				}else{
					var arr=[];
					$.ajax({
						url:baseUrl+'/levels',
						type:'get',
						async:false,
						success:function(levels){
							var dats=levels.rows;
							for(var j=0;j<dats.length;j++){
								var obj = {};
								obj.text = dats[j].name;
								obj.id = dats[j].id;
								arr.push(obj);
							}
						}
					});
					$('#_levelId').select2({
						data: arr
					});
				}
			}
		</script>
	</body>

</html>
